import React, { Component } from 'react';
import { Modal, Form, message, Radio, InputNumber, Row, Card, Tree } from 'antd';

const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const { TreeNode } = Tree;
export default class setCutIn extends Component {
  state = {
    brightnessVal: 1,
    devIdArray: this.props.selectedRows,
  };

  onChange = brightnessVal => {
    this.setState({
      brightnessVal,
    });
  };
  onCheck = checkedKeys => {
    //console.log('selectkeys', checkedKeys);
    this.setState({ devIdArray: checkedKeys });
  };
  handleSet = () => {
    this.props.form.validateFields((err, values) => {
      if (!err) {
        const { icTaskId, dispatch } = this.props;
        const { exeStatus } = values;
        
        dispatch({
          type: 'cutinlist/setStart',
          payload: { icTaskId, exeStatus },
          callback: () => {
            message.success('设置启停成功.');
          },
        });
        this.props.handleModalVisible(false);
      }
    });
  };

  render() {
    const { modalVisible, form, handleModalVisible, selectedRows } = this.props;
    return (
      <Modal
        title="设置插播启停"
        visible={modalVisible}
        onOk={this.handleSet}
        onCancel={() => handleModalVisible(false, 'init')}
      >
        <Form>
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="插播启停">
            {form.getFieldDecorator('exeStatus', {
              initialValue: 1,
              rules: [{ required: true, message: '请选择插播任务开关...' }],
            })(
              <RadioGroup>
                <Radio value={0}>关</Radio>
                <Radio value={1}>开</Radio>
              </RadioGroup>
            )}
          </FormItem>
        </Form>
      </Modal>
    );
  }
}
